cmake_minimum_required(VERSION 3.5)

project(GUI VERSION 0.1 LANGUAGES CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)


set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets LinguistTools)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets LinguistTools)

set(TS_FILES GUI_zh_CN.ts)

set(PROJECT_SOURCES_GUI
        main.cpp
        mygui.cpp
        mygui.h
        mygui.ui
        ${TS_FILES}
)
add_executable(GUI WIN32 ${PROJECT_SOURCES_GUI})

#target_link_libraries(GUI core Qt${QT_VERSION_MAJOR}::Widgets)
find_library(CORE_LIB NAME core.dll PATHS ../bin/)
target_link_libraries(GUI  ${CORE_LIB})


target_link_libraries(GUI Qt${QT_VERSION_MAJOR}::Widgets)
#if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
#    qt_add_executable(GUI
#        MANUAL_FINALIZATION
#        ${PROJECT_SOURCES_GUI}
#    )
## Define target properties for Android with Qt 6 as:
##    set_property(TARGET GUI APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
##                 ${CMAKE_CURRENT_SOURCE_DIR}/android)
## For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation

#    qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
#else()
#    add_executable(GUI ${PROJECT_SOURCES_GUI})
#    qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
#endif()
#find_library(CORE_LIB NAME core.dll PATHS ../bin/)
#target_link_libraries(GUI  ${CORE_LIB})


#target_link_libraries(GUI PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)




#set_target_properties(GUI PROPERTIES  TRUE)

#if(QT_VERSION_MAJOR EQUAL 6)
#    qt_finalize_executable(GUI)
#endif()
